home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / HandHeldPCPro30 / sdk.exe / Jupiter SDK / data1.cab / MFC / src / dlgfr.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-19  |  3.7 KB  |  139 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11. #include "stdafx.h"
  12. #ifndef _INC_STDDEF
  13. #include <stddef.h>     // for offsetof macro
  14. #endif
  15.  
  16. #if !defined(_WIN32_WCE_NO_FINDREPLACE)
  17. #ifdef AFX_AUX_SEG
  18. #pragma code_seg(AFX_AUX_SEG)
  19. #endif
  20.  
  21. #ifdef _DEBUG
  22. #undef THIS_FILE
  23. static char THIS_FILE[] = __FILE__;
  24. #endif
  25.  
  26. #define new DEBUG_NEW
  27.  
  28. /////////////////////////////////////////////////////////////////////////////
  29. // Find/FindReplace dialogs
  30.  
  31. CFindReplaceDialog::CFindReplaceDialog() : CCommonDialog(NULL)
  32. {
  33.     memset(&m_fr, 0, sizeof(m_fr));
  34.     m_szFindWhat[0] = '\0';
  35.     m_szReplaceWith[0] = '\0';
  36.  
  37.     m_fr.Flags = FR_ENABLEHOOK;
  38.     if (!afxData.bWin4 && AfxHelpEnabled())
  39.         m_fr.Flags |= FR_SHOWHELP;
  40.     m_fr.lpfnHook = WCE_IF((LPFRHOOKPROC)wce_FirstDlgProc, (COMMDLGPROC)_AfxCommDlgProc);
  41.     m_fr.lStructSize = sizeof(m_fr);
  42.     m_fr.lpstrFindWhat = (LPTSTR)m_szFindWhat;
  43. }
  44.  
  45. void CFindReplaceDialog::PostNcDestroy()
  46. {
  47.     ASSERT(m_hWnd == NULL);
  48.     delete this;
  49. }
  50.  
  51. BOOL CFindReplaceDialog::Create(BOOL bFindDialogOnly,
  52.     LPCTSTR lpszFindWhat, LPCTSTR lpszReplaceWith,
  53.     DWORD dwFlags, CWnd* pParentWnd)
  54. {
  55.     ASSERT_VALID(this);
  56.     ASSERT(m_fr.Flags & FR_ENABLEHOOK);
  57.     ASSERT(m_fr.lpfnHook != NULL);
  58.  
  59.     m_nIDHelp = bFindDialogOnly ? AFX_IDD_FIND : AFX_IDD_REPLACE;
  60.  
  61.     m_fr.wFindWhatLen = _countof(m_szFindWhat);
  62.     m_fr.lpstrReplaceWith = (LPTSTR)m_szReplaceWith;
  63.     m_fr.wReplaceWithLen = _countof(m_szReplaceWith);
  64.     m_fr.Flags |= dwFlags;
  65.  
  66.     if (pParentWnd == NULL)
  67.         m_fr.hwndOwner = AfxGetMainWnd()->GetSafeHwnd();
  68.     else
  69.     {
  70.         ASSERT_VALID(pParentWnd);
  71.         m_fr.hwndOwner = pParentWnd->m_hWnd;
  72.     }
  73.     ASSERT(m_fr.hwndOwner != NULL); // must have a parent for modeless dialog
  74.  
  75.     if (lpszFindWhat != NULL)
  76.         lstrcpyn(m_szFindWhat, lpszFindWhat, _countof(m_szFindWhat));
  77.  
  78.     if (lpszReplaceWith != NULL)
  79.         lstrcpyn(m_szReplaceWith, lpszReplaceWith, _countof(m_szReplaceWith));
  80.  
  81.     HWND hWnd;
  82.  
  83.     AfxHookWindowCreate(this);
  84.     if (bFindDialogOnly)
  85.         hWnd = ::WCE_FCTN(FindText)(&m_fr);
  86.     else
  87.         hWnd = ::WCE_FCTN(ReplaceText)(&m_fr);
  88.     if (!AfxUnhookWindowCreate())
  89.         PostNcDestroy();
  90.  
  91.     ASSERT(hWnd == NULL || hWnd == m_hWnd);
  92.     return hWnd != NULL;
  93. }
  94.  
  95. CFindReplaceDialog* PASCAL CFindReplaceDialog::GetNotifier(LPARAM lParam)
  96. {
  97.     ASSERT(lParam != NULL);
  98.     CFindReplaceDialog* pDlg;
  99.  
  100.     pDlg = (CFindReplaceDialog*)(lParam - offsetof(CFindReplaceDialog, m_fr));
  101.     ASSERT_VALID(pDlg);
  102.     ASSERT_KINDOF(CFindReplaceDialog, pDlg);
  103.  
  104.     return pDlg;
  105. }
  106.  
  107. ////////////////////////////////////////////////////////////////////////////
  108. // CFindReplaceDialog diagnostics
  109.  
  110. #ifdef _DEBUG
  111. void CFindReplaceDialog::Dump(CDumpContext& dc) const
  112. {
  113.     CDialog::Dump(dc);
  114.  
  115.     dc << "m_fr.hwndOwner = " << (UINT)m_fr.hwndOwner;
  116.     dc << "\nm_fr.Flags = " << (LPVOID)m_fr.Flags;
  117.     dc << "\nm_fr.lpstrFindWhat = " << m_fr.lpstrFindWhat;
  118.     dc << "\nm_fr.lpstrReplaceWith = " << m_fr.lpstrReplaceWith;
  119.  
  120. #if !defined(_WIN32_WCE)
  121.     if (m_fr.lpfnHook == (COMMDLGPROC)_AfxCommDlgProc)
  122.         dc << "\nhook function set to standard MFC hook function";
  123.     else
  124.         dc << "\nhook function set to non-standard hook function";
  125. #endif // _WIN32_WCE
  126.  
  127.     dc << "\n";
  128. }
  129. #endif //_DEBUG
  130.  
  131. #ifdef AFX_INIT_SEG
  132. #pragma code_seg(AFX_INIT_SEG)
  133. #endif
  134.  
  135. IMPLEMENT_DYNAMIC(CFindReplaceDialog, CDialog)
  136.  
  137. ////////////////////////////////////////////////////////////////////////////
  138. #endif // _WIN32_WCE_NO_FINDREPLACE
  139.